import { jssdksignature } from '@/api/server';
import { apiService } from '@/api/apiService';
import wx from 'weixin-js-sdk';

export function isIOS () {
    const isIPhone = navigator.userAgent.includes('iPhone');
    const isIPad = navigator.userAgent.includes('iPad');
    return isIPhone || isIPad;
}
// 获取微信定位授权
export function requestWxStr (success) {
    const param = {};
    if (window.__wxjs_is_wkwebview) {
        param.isios = true;
    }
    apiService({
        api: jssdksignature,
        param: param,
        success: (data) => {
            wx.config({
                debug: false,
                appId: data.values.appId,
                timestamp: data.values.timestamp,
                nonceStr: data.values.nonceStr,
                signature: data.values.signature,
                jsApiList: ['getLocation', 'openLocation']
            });
            success && success();
        }
    });
};
